<template>
    <div>login</div>
    <button @click="paramsPush">params跳转</button>
    <button @click="queryPush">query跳转</button>
</template>

<script setup>
import { useRoute, useRouter } from "vue-router";
const route = useRoute();
const router = useRouter();
const paramsPush = () => {
    router.push({
        name: "home",
        params: { id: 1 },
    });
    //path跳转不了，name可以
    // router.push({
    //     path: "/home",
    //     params: { id: 1 },
    // });
};
const queryPush = () => {
    //path,name都可以跳转
    // router.push({
    //     name: "about",
    //     query: { id: 1, name: "张三" },
    // });
    router.push({
        path: "about",
        query: { id: 1, name: "张三" },
    });
};
</script>

<style scoped></style>
